import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import electron from 'vite-plugin-electron'
import path from 'path';

export default (({ mode }) => {
  console.log('mode', mode)
  const baseUrl = loadEnv(mode, process.cwd()).VITE_BASE_URL;
  return defineConfig({
    plugins: [
      vue(),
      electron({
        // 主进程入口文件
        entry: './src-electron/main.js'
      })
    ],
    /*开发服务器选项*/
    server: {
      host: '0.0.0.0',
      port: 9000,
      open: true,
      https: false,
      proxy: {
        '/starlink-api': {
          target: baseUrl,
          changeOrigin: true,
        },
      },
    },
    resolve: {
      alias: {
        '@': path.resolve('./src'), // @代替src
        '#': path.resolve('./types'), // #代替types
      },
    },
  })
})
